<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="jquery-3.6.0.min.js"></script>
    <style>
       #imgDiv{
            position: absolute;
        }
        #myDiv{
            width: 100%;
            height: 1000px;
            background-color: black;
        }
    </style>
</head>
<body>
    <h1>谭君容18900829</h1>
    <div id="myDiv">
        <div id="imgDiv">
            <img class="pic" src="./img/player_left.gif">
        </div>
    </div>
    <script>
            $("#myDiv").mousedown(function(e){
                //屏幕的XY值
                let x=e.pageX-50;
                let y=e.pageY-50;
                //$("#imgDiv")=stop();
                let picleft= parseInt($("#imgDiv").css("left"));//获取图片的left
                //比较图片的宽度和点击屏幕处的宽度
                if( picleft>e.pageX ){
                    $(".pic").attr("src","./img/player_left.gif");//变换照片
                }
                else{
                    $(".pic").attr("src","./img/player_right.gif");
                }
                //移动图片
                $("#imgDiv").animate({
                    left: x,
                    top: y
                },1500)
            })
    </script>        
</body>
</html>